using System;
using System.Collections.Generic;
using System.Text;
using WindowsLive.Writer.Api;

namespace TimHeuer.WindowsLiveWriter.S34Writer
{
    public class S3Context
    {
        private const string ACCESS_KEY_ID = "AccessKeyId";
        private const string SECRET_ACCESS_KEY = "SecretAccessKey";
        private const string AUTO_UPLOAD_WITH_FILE_NAME = "AutoUploadWithFileName";

        #region Constructors
        public S3Context(IProperties pluginSettings)
        {
            _pluginSettings = pluginSettings;
        }
        #endregion Constructors

        #region Member Variables
        private IProperties _pluginSettings;
        #endregion Member Variables

        #region Public Properties
        public string AccessKeyId
        {
            get { return _pluginSettings.GetString(ACCESS_KEY_ID, string.Empty); }
            set { _pluginSettings.SetString(ACCESS_KEY_ID, value); }
        }
        public string SecretAccessKey
        {
            get { return _pluginSettings.GetString(SECRET_ACCESS_KEY, string.Empty); }
            set { _pluginSettings.SetString(SECRET_ACCESS_KEY, value); }
        }
        public bool AutoUploadWithFileName
        {
            get { return _pluginSettings.GetBoolean(AUTO_UPLOAD_WITH_FILE_NAME, false); }
            set { _pluginSettings.SetBoolean(AUTO_UPLOAD_WITH_FILE_NAME, value); }
        }

        public bool IsValid
        {
            get
            {
                // The context is "valid" (but not "validated") if the access key
                // and secret access key are specified.
                return (!String.IsNullOrEmpty(AccessKeyId) && !String.IsNullOrEmpty(SecretAccessKey));
            }
        }
        #endregion Public Properties
    }
}
